package com.cswangdao.controller.user;

import com.cswangdao.domain.vo.WXCatalogIndexVo;
import com.cswangdao.result.Result;
import com.cswangdao.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wx/catalog")
@Slf4j
public class WxCatalogController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/index")
    public Result<WXCatalogIndexVo> index(){
        log.info("获取商品分类信息");
        WXCatalogIndexVo wxCatalogIndexVo = categoryService.getCatalogIndex();
        return Result.success(wxCatalogIndexVo);
    }

    @GetMapping("/current")
    public Result<WXCatalogIndexVo> current(@RequestParam("id") Integer id){
        log.info("获取当前目录的二级目录信息");
        WXCatalogIndexVo categories = categoryService.getCurrenCatalogByPid(id);
        return Result.success(categories);
    }
}
